package com.zhl.emp_manage.service;

import com.zhl.emp_manage.entity.Emp;
import com.zhl.emp_manage.mapper.EmpMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class EmpService {
    @Autowired
    private EmpMapper empMapper;

    //查询所有
    public List<Emp> getEmpAll() {
        return empMapper.getEmpAll();
    }

    //添加
    public boolean addEmp(Emp emp) {
        return empMapper.addEmp(emp);
    }

    //修改
    public boolean updateEmp(Emp emp) {
        return empMapper.updateEmp(emp);
    }

    //删除
    public boolean deleteEmp(Integer id) {
        return empMapper.deleteEmp(id);
    }

    //根据id查询
    public Emp getById(Integer id) {
        return empMapper.getById(id);
    }

    //分页查询
    public List<Emp> getEmp(Integer page, Integer limit) {
        return empMapper.getEmpAll();
    }

    //模糊查询
    public List<Emp> getEmpLike(String name) {
        return empMapper.getEmpLike(name);
    }

    //查询部门下的所有员工
    public List<Emp> getEmpByDeptNo(Integer deptNo) {
        return empMapper.getEmpByDeptNo(deptNo);
    }

    //动态返回查询结果
    public Emp queryWrapper(List<String> wrapper, Integer id) {
        return empMapper.queryWrapper(wrapper, id);
    }
}
